package com.ys.http.api;


import com.ys.http.entry.Resp;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HeaderMap;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;
import retrofit2.http.Url;

public interface ApiService {

    //  网络请求，异步

    @GET("gettest")
    Observable<Resp<String>> getInfo(@Query("id") String id);

    @GET("gettest")
    Observable<Resp<String>> getInfo(@QueryMap Map<String, String> map);

    @FormUrlEncoded
    @POST("test/test")
    Observable<Resp<String>> login(@Field("name") String name, @Field("password") String password);

    @POST("test/test2")
    Observable<Resp<String>> login(@Body RequestBody body);

    @GET
    <T> Observable<String> get(@Url String url);

    @GET
    <T> Observable<String> get(@Url String url, @QueryMap Map<String, String> params);

    @GET
    <T> Observable<String> headerGet(@Url String url, @HeaderMap Map<String, String> headers);

    @GET
    <T> Observable<String> headerGet(@Url String url, @QueryMap Map<String, String> params, @HeaderMap Map<String, String> headers);

    @POST
    <T> Observable<String> post(@Url String url);

    @POST
    <T> Observable<String> post(@Url String url, @Body RequestBody body);

    @POST
    <T> Observable<String> post(@Url String url, @HeaderMap Map<String, String> headers);

    @POST
    <T> Observable<String> post(@Url String url, @HeaderMap Map<String, String> headers, @Body RequestBody body);

    @POST
    <T> Observable<String> post(@Url String url, @Body Object bean);

    @POST
    <T> Observable<String> post(@Url String url, @HeaderMap Map<String, String> headers, @Body Object bean);


    // 网络请求 同步
    @POST
    Call<ResponseBody> postSync(@Url String url);

    @POST
    Call<ResponseBody> postSync(@Url String url, @Body RequestBody body);

    @POST
    Call<ResponseBody> postSync(@Url String url, @HeaderMap Map<String, String> headers);

    @POST
    Call<ResponseBody> postSync(@Url String url, @HeaderMap Map<String, String> headers, @Body RequestBody body);

    @POST
    Call<ResponseBody> postSync(@Url String url, @Body Object bean);

    @POST
    Call<ResponseBody> postSync(@Url String url, @HeaderMap Map<String, String> headers, @Body Object bean);
}
